<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="gae.colopl.*" %>
<%@ page import="gae.colopl.bean.*" %>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
<!-- above set at the top of the file will set     -->
<!-- the browser's rendering engine into           -->
<!-- "Quirks Mode". Replacing this declaration     -->
<!-- with a "Standards Mode" doctype is supported, -->
<!-- but may lead to some differences in layout.   -->

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>お土産一括ギフト</title>
  </head>
  
  <body>
    <h2>お土産一括ギフト</h2>
    <div>ギフトするお土産の選択</div>
    <br>
    <%
    boolean isViewAll = (Boolean)session.getAttribute("present.souvenir.view.all");
    boolean isSelectAll = (Boolean)session.getAttribute("present.souvenir.select");
    if (isViewAll) {
    %>
    <form method="POST" action="<%=response.encodeUrl("selectSouvenir.do") %>">
      <div>現在、あなたが所持している全てのお土産を表示しています。</div>
      <input type="submit" value="相手の所持数が0個のだけ表示">
      <input type="hidden" name ="listView" value="zero">
    </form>
    <%
    } else {
    %>
    <form method="POST" action="<%=response.encodeUrl("selectSouvenir.do") %>">
      <div>現在、相手の所持数が0個のお土産のみ表示しています。</div>
      <input type="submit" value="全てのお土産を表示">
      <input type="hidden" name ="listView" value="all">
    </form>
    <%
    }
    if (isSelectAll) {
    %>
    <form method="POST" action="<%=response.encodeUrl("selectSouvenir.do") %>">
      <input type="submit" value="全て選択解除">
      <input type="hidden" name ="select" value="none">
    </form>
    <%
    } else {
    %>
    <form method="POST" action="<%=response.encodeUrl("selectSouvenir.do") %>">
      <input type="submit" value="全て選択">
      <input type="hidden" name ="select" value="all">
    </form>
    <%
    }
    %>
    <form method="POST" action="<%=response.encodeUrl("presentSouvenir.do") %>">
      <table border=1>
        <caption>お土産一覧</caption>
        <tr bgcolor="#cccccc">
          <th></th>
          <th>お土産</th>
          <th>自</th>
          <th>相</th>
        </tr>
  <%
  User user = (User)session.getAttribute("userInfo");
  List<PresentSouvenir> souvenirs = (List<PresentSouvenir>)session.getAttribute("present.souvenir");
  if (souvenirs != null) {
	 if (souvenirs.size() > 0) {
	     for (int i = 0; i < souvenirs.size(); i++) {
	         PresentSouvenir souvenir = souvenirs.get(i);
	         if (isViewAll || isViewAll == false & souvenir.getOtherCount() == 0) {
  %>
    <tr align=center>
  <% 
                 if (isSelectAll) {
  %>
      <td><input type="checkbox" name="omiyageID" value="<%=souvenir.getOmiyageID() %>" checked></td>
  <% 
                 } else {
  %>
      <td><input type="checkbox" name="omiyageID" value="<%=souvenir.getOmiyageID() %>"></td>
  <% 
                 }
  %>
      <td><%=souvenir.getName() %></td>
      <td><%=souvenir.getMyCount() %></td>
      <td><%=souvenir.getOtherCount() %></td>
    </tr>
  <%
	         }
	     }
	 }
  }
  %>
  </table>
  <br>
  <div>それぞれ
    <select name="num"> 
      <option value="1">1個</option> 
      <option value="2">2個</option> 
      <option value="3">3個</option> 
      <option value="4">4個</option> 
      <option value="5">5個</option> 
      <option value="6">6個</option> 
      <option value="7">7個</option> 
      <option value="8">8個</option> 
      <option value="9">9個</option> 
      <option value="10">10個</option> 
      <option value="20">20個</option> 
      <option value="30">30個</option> 
      <option value="40">40個</option> 
      <option value="50">50個</option> 
    </select>個ギフトする
  </div>
  <input type="submit" value="OK">
  </form>
    <br>
  <div><a href="<%=response.encodeUrl("menu.do") %>">メニュー</a></div>
  <br>
  <div><a href="<%=response.encodeUrl("logout.do") %>">ログアウト</a></div>
  <br>
  </body>
</html>
